#ifndef __M_QUEUE_H__ 
#define __M_QUEUE_H__ 
#include<iostream>
#include<vector>

namespace bitlog 
{
    template<typename T>
    class ring_queue
    {
    private:
        size_t _capacity;
        size_t _read_pos;
        size_t _write_pos;
        std::vector<T> _v;
    public:
        explicit RingQueue(size_t capacity);
        void push(const T &&item); 
        const T& front();
        T& front();
        void pop();
        bool empty();
        bool full(); 
    };

    template<typename T>
    class block_queue
    {
    private:
        ring_queue<T> _q;
        std::mutex _mutex;
        std::condition_variable _cond_push;
        std::condition_variable _cond_pop; 
    public:
        block_queue(size_t capacity);
        void enqueue(T &&item);
        T& dequeue(T std::chrono::milliseconds duration = -1);
        size_t size(); 
    };
}

#endif 
